package cate.game.demo.batch;

import cate.game.GameBody;
import cp.solution.business.game.cmd.GameBatchCmd;
import easy.java.practice.errorcode.EcException;

public class GameBatchCmdHandlers {

    public interface BatchExecutor {
        String exe(GameBody game, GameBatchCmd cmd);
    }

    public static BatchExecutor getExecutor(GameBatchCmd cmd) {
        switch (cmd.type) {
            case GameBatchCmd.TYPE_ECHO: return doEcho;
            case GameBatchCmd.TYPE_STATUS: return doStatus;
            default: throw new EcException("不支持的cmd.type="+cmd.type);
        }
    }

    private static final BatchExecutor doEcho = (g, c) -> "echo完成"+System.currentTimeMillis();

    private static final BatchExecutor doStatus = (g, c) -> {
        StringBuilder sb = new StringBuilder();
        sb.append("状态是：");
        sb.append("累计创建角色数量统计="+g.status.data.masterCreateNum);
        return sb.toString();
    };

}
